<?php

namespace app\api\controller;

use app\data\model\DataQiyeRzinfo;
use think\admin\Controller;
use think\facade\Db;
use think\facade\Request;

class Qiye extends Controller
{

    //查看企业是否认证
    public function chaIsrz()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }

        $rz_info = Db::name("data_qiye_rzinfo")->where('user_id', $user_id)->where('deleted', 0)->find();


        if (empty($rz_info)) {
            $is_rz      = 0;
            $rz_shenfen = '';
        } else {
            $is_rz      = 1;
            $rz_shenfen = Db::name("data_sbr_type")->where('id', $rz_info['sbr_type'])->value('name');
        }

        return_msg(200, '查询成功', ['is_rz' => $is_rz, 'rz_shenfen' => $rz_shenfen]);
    }

    //获取申报人身份
    public function getSbrSfList()
    {

        $list = Db::name("data_sbr_type")->where('id', '<>', 1)->where('deleted', 0)->select()->toArray();

        return_msg(200, '查询成功', $list);
    }


    //获取企业标签分类
    public function getQybqList()
    {

        $list = Db::name("data_qiye_biaoqian")->where('deleted', 0)->select()->toArray();

        return_msg(200, '查询成功', $list);
    }

    //提交认证
    public function tijiaoRz()
    {

        $user_id   = input('user_id');
        $qymc      = input('qymc');
        $tyxydm    = input('tyxydm');
        $yyzz      = input('yyzz');
        $sbr_type  = input('sbr_type');
        $sbr_xm    = input('sbr_xm');
        $sbr_sfzh  = input('sbr_sfzh');
        $sbr_phone = input('sbr_phone');
        $xzbm      = input('xzbm');
        $zczj      = input('zczj');
        $code      = input('code');
        //        $qybq_ids = Request::instance()->post('qybq_ids/a');

        //        $qybq = '';
        //        if(!empty($qybq_ids)){
        //            $qybq = implode(',',$qybq_ids);
        //        }

        if (empty($user_id)) {
            return_error('缺少参数user_id');
        }

        $is_dsh_count = Db::name("data_qiye_rzinfo_dsh")->where('user_id', $user_id)->where('deleted', 0)->where('sh_status', 0)->count();

        if (!empty($is_dsh_count)) {
            return_error('企业认证审核中，请勿重复提交');
        }


        $is_count = Db::name("data_qiye_rzinfo")->where('user_id', $user_id)->where('deleted', 0)->count();

        if (!empty($is_count)) {
            return_error('已完成认证，请不要重复认证');
        }


        $xinxiku = Db::name("data_qiye_xinxiku")->where('tyxydm', $tyxydm)->where('code', $code)->find();
        if (empty($xinxiku)) {
            return_error('提交的企业信息不存在，请仔细核对统一信用代码或绑定码');
        }


        //开启事务
        Db::startTrans();
        try {
            $data_qiye_rzinfo = [
                'user_id'     => $user_id,
                'qymc'        => $xinxiku['qymc'],
                'tyxydm'      => $xinxiku['tyxydm'],
                'yyzz'        => $yyzz,
                'sbr_type'    => $sbr_type,
                'sbr_xm'      => $sbr_xm,
                'sbr_sfzh'    => $sbr_sfzh,
                'sbr_phone'   => $sbr_phone,
                'xzbm'        => $xzbm,
                'zczj'        => $zczj,
                'qybq'        => $xinxiku['qybq'],
                'create_time' => time(),
                'qrxxk_id'    => $xinxiku['id'],
            ];

            Db::name("data_qiye_rzinfo_dsh")->insert($data_qiye_rzinfo);

            //            Db::name("data_user")->where('id',$user_id)->update(['nickname'=>$qymc]);

            Db::commit();

            return_msg(200, '提交成功');
        }
        catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            return_error('提交失败');
        }
    }


    //我的授权列表
    public function renzhengShenheList()
    {

        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }
        $info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();

        if ($info['qiyesf'] != 1) {

            return_error('你不是法人，无法使用此功能');
        }

        $list = Db::name("data_qiye_rzinfo_dsh")->where('qrxxk_id', $info['qrxxk_id'])->order('create_time desc')->select()->toArray();

        foreach ($list as &$item) {
            if ($item['sh_status'] == 0) {
                $item['sh_status_txt'] = '未审核';
            } elseif ($item['sh_status'] == 1) {
                $item['sh_status_txt'] = '已审核';
            } elseif ($item['sh_status'] == 9) {
                $item['sh_status_txt'] = '不通过';
            }
        }


        return_msg(200, '获取成功', $list);

    }


    //处理认证授权
    public function chuliShouquan()
    {

        $id    = input('id');
        $chuli = input('chuli');

        if (empty($id) || empty($chuli)) {
            return_error('缺少参数');
        }

        $info = Db::name("data_qiye_rzinfo_dsh")->where('id', $id)->find();

        if (empty($info)) {
            return_error('未查询到记录');
        }

        if ($info['sh_status'] != 0) {
            return_error('记录状态异常，无法授权');
        }


        if ($chuli == 1) {

            $data_qiye_rzinfo = [
                'user_id'     => $info['user_id'],
                'qymc'        => $info['qymc'],
                'tyxydm'      => $info['tyxydm'],
                'yyzz'        => $info['yyzz'],
                'sbr_type'    => $info['sbr_type'],
                'sbr_xm'      => $info['sbr_xm'],
                'sbr_sfzh'    => $info['sbr_sfzh'],
                'sbr_phone'   => $info['sbr_phone'],
                'xzbm'        => $info['xzbm'],
                'zczj'        => $info['zczj'],
                'qybq'        => $info['qybq'],
                'create_time' => time(),
                'qrxxk_id'    => $info['qrxxk_id'],
                'qiyesf'      => 2,
            ];

            Db::name("data_qiye_rzinfo")->insert($data_qiye_rzinfo);
            Db::name("data_user")->where('id', $info['user_id'])->update(['nickname' => $info['qymc']]);


            $sh_status = 1;
        } else {
            $sh_status = 9;
        }

        Db::name("data_qiye_rzinfo_dsh")->where('id', $id)->update(['sh_status' => $sh_status]);

    }


    //获取企业认证信息
    public function getQyRzinfo()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }
        $info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();

        if(empty($info)){

            $user = Db::name("data_user")->where('id',$user_id)->find();
            $info['qymc'] = '待认证企业';
            $info['sbr_phone'] = $user['phone'];

            $info['qybq_list'] = [];
            $info['qybq_txt'] = '';
            $info['qyszd_id'] = '';
            $info['qyszd_txt'] = '';
            $info['user_id'] = $user_id;
            $info['tyxydm'] = '';
            $info['is_enterprise_user'] = 0;
            $info['rz_status_txt'] = '待认证';
        }else{

            if (empty($info['qybq'])) {
                $info['qybq_list'] = [];
                $info['qybq_txt'] = '';

            } else {
                $info['qybq_list'] = explode(',', $info['qybq']);

                $qybq_txt = '';
                foreach ($info['qybq_list'] as $item){

                    if(!empty($qybq_txt)){
                        $qybq_txt.=',';
                    }
                    $qybq_txt.= Db::name("data_qiye_biaoqian")->where('id',$item)->value('name');
                }

                $info['qybq_txt'] = $qybq_txt;
            }

            $info['rz_status_txt'] = '已认证';
            $info['is_enterprise_user'] = 1;

            if(!empty($info['qyszd_id'])){
                $info['qyszd_txt'] = Db::name("data_qyszd")->where('id',$info['qyszd_id'])->value('name');
            }else{
                $info['qyszd_txt'] = '';
            }


        }




        $info['is_tijiao'] = Db::name("data_qiye_rzinfo_dsh")->where('user_id',$info['user_id'])->where('sh_status',0)->count();





        return_msg(200, '获取成功', $info);
    }


    //获取企业是否已认证
    public function getIsQyRz(){
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }
        $info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();

        if(empty($info)){
            return_msg(200, '获取成功', 0);
        }else{
            return_msg(200, '获取成功', 1);
        }


    }


    //注销企业认证
    public function zhuxiao()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }
        //开启事务
        Db::startTrans();
        try {
            Db::name("data_qiye_rzinfo")->where('user_id', $user_id)->where('deleted', 0)->update(['deleted' => 1]);

            Db::name("data_user")->where('id', $user_id)->update(['nickname' => '已注销企业信息']);

            Db::commit();

            return_msg(200, '注销成功');
        }
        catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            return_error('注销失败');
        }
    }

    //修改企业标签
    public function updateQybq()
    {
        $user_id  = input('user_id');
        $tyxydm   = input('tyxydm');
        $qybq_ids = Request::instance()->post('qybq_ids/a');

        $qybq = '';
        if (!empty($qybq_ids)) {
            $qybq = implode(',', $qybq_ids);
        }

        //开启事务
        Db::startTrans();
        try {
            Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('tyxydm', $tyxydm)->update(['qybq' => $qybq]);
            Db::name('data_qiye_xinxiku')->where('tyxydm', $tyxydm)->update(['qybq' => $qybq]);

            Db::commit();

            return_msg(200, '操作成功');
        }
        catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            return_error('操作失败');
        }

    }


    //提交企呼我应
    public function tijiaoQhwy()
    {
        $user_id   = input('user_id');
        $qymc      = input('qymc');
        $sbr_xm    = input('sbr_xm');
        $sbr_phone = input('sbr_phone');
        $sqms      = input('sqms');

        if (empty($user_id)) {
            return_error('缺少参数user_id');
        }

        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();
        if (empty($rz_info)) {
            return_error('请先完成企业认证');
        }


        $is_count = Db::name("data_qhwy_user")->where('user_id', $user_id)->where('tj_time', '>=', time() - 10)->count();
        if ($is_count) {
            return_error('请勿重复提交');
        }

        $data_qhwy_user_data = [
            'user_id'   => $user_id,
            'qymc'      => $qymc,
            'sbr_xm'    => $sbr_xm,
            'sbr_phone' => $sbr_phone,
            'sqms'      => $sqms,
            'tj_status' => 1,
            'tj_time'   => time(),
            'qrxxk_id'  => $rz_info['qrxxk_id'],
        ];

        Db::name("data_qhwy_user")->insert($data_qhwy_user_data);


        return_msg(200, '操作成功');

    }


    //查看企呼我应列表
    public function getQhwyList()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数user_id');
        }

        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();
        if (empty($rz_info)) {
            return_error('未查询到企业认证信息');
        }

        $list = Db::name("data_qhwy_user")->where('qrxxk_id', $rz_info['qrxxk_id'])->where('deleted', 0)->order('create_at desc')->select()->toArray();

        foreach ($list as &$item) {
            if (!empty($item['cluser_id'])) {
                $item['cluser_name'] = Db::name("data_user")->where('id', $item['cluser_id'])->value('nickname');
            } else {
                $item['cluser_name'] = '';
            }

            $item['tj_time_txt'] = date('Y-m-d H:i:s', $item['tj_time']);


        }


        return_msg(200, '查询成功', $list);


    }

    public function getQhwyStatistics()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_msg(200, '查询成功', ['submitted' => 0, 'finished' => 0]);
        }

        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();
        if (empty($rz_info)) {
            return_error('未查询到企业认证信息');
        }
        
        $submitted = Db::name("data_qhwy_user")->where('qrxxk_id', $rz_info['qrxxk_id'])->where('deleted', 0)->whereIn('tj_status', ['1', '2'])->count();
        $finished  = Db::name("data_qhwy_user")->where('qrxxk_id', $rz_info['qrxxk_id'])->where('deleted', 0)->whereIn('tj_status', ['3', '4'])->count();
        return_msg(200, '查询成功', ['submitted' => $submitted, 'finished' => $finished]);
    }

    //查看企呼我应详情
    public function chakanXq()
    {

        $id = input('id');

        if (empty($id)) {
            return_error('缺少参数id');
        }

        $info = Db::name("data_qhwy_user")->where('id', $id)->find();

        if (!empty($info['tj_time'])) {
            $info['tj_time_txt'] = date('Y-m-d H:i:s', $info['tj_time']);
        } else {
            $info['tj_time_txt'] = '';
        }


        if (!empty($info['cl_time'])) {
            $info['cl_time_txt'] = date('Y-m-d H:i:s', $info['cl_time']);
        } else {
            $info['cl_time_txt'] = '';
        }

        if (!empty($info['cluser_id'])) {
            $info['cluser_name'] = Db::name("data_user")->where('id', $info['cluser_id'])->value('nickname');
        } else {
            $info['cluser_name'] = '';
        }

        return_msg(200, '查询成功', $info);

    }

    //企呼我应评价
    public function pingjia()
    {

        $id      = input('id');
        $user_id = input('user_id');
        $pf      = input('pf');
        $pjnr    = input('pjnr');


        if (empty($id) || empty($user_id)) {
            return_error('缺少参数');
        }

        $info = Db::name("data_qhwy_user")->where('id', $id)->find();
        if (empty($info)) {
            return_error('未查询到相应记录');
        }

        if ($info['tj_status'] != 3) {
            return_error('状态：不可评价');
        }

        if ($info['user_id'] != $user_id) {
            return_error('只可对自己的发布评价');
        }

        Db::name("data_qhwy_user")->where('id', $id)->update(['pf' => $pf, 'pjnr' => $pjnr, 'tj_status' => 3]);

        return_msg(200, '操作成功');
    }


    //政策订阅
    public function zhengceDingyue()
    {
        $zc_id   = input('zc_id');
        $user_id = input('user_id');

        if (empty($zc_id) || empty($user_id)) {
            return_error('请先登录');
        }

        $dingyue_conut = Db::name("data_zhengceku_user_dy")->where('user_id', $user_id)->where('zc_id', $zc_id)->count();


        if (!empty($dingyue_conut)) {
            return_error('已经订阅，请勿重复订阅');
        }


        Db::name("data_zhengceku_user_dy")->insert(['user_id' => $user_id, 'zc_id' => $zc_id]);

        return_msg(200, '订阅成功');
    }





    //查看我的政策订阅列表
    public function myZhengceDingyueList()
    {

        $user_id = input('user_id');

        if (empty($user_id)) {
            return_error('缺少参数');
        }

        $list = Db::name("data_zhengceku_user_dy")->where('user_id', $user_id)->select()->toArray();

        foreach ($list as &$dy) {

            $info = Db::name("data_zhengceku")->where('id', $dy['zc_id'])->find();

            if (!empty($info['admin_id'])) {
                $info['admin_name'] = Db::name("system_user")->where('id', $info['admin_id'])->value('nickname');
            } else {
                $info['admin_name'] = '';
            }

            if (!empty($info['ctrq'])) {

                $info['ctrq_txt'] = date('Y-m-d', $info['ctrq']);

            } else {
                $info['ctrq_txt'] = '';
            }


            if (!empty($info['sbksrq'])) {

                $info['sbksrq_txt'] = date('Y-m-d', $info['sbksrq']);

            } else {
                $info['sbksrq_txt'] = '';
            }

            if ($info['riqitype'] == 1) {

                if (!empty($info['sbjzrq'])) {
                    if ($info['sbjzrq'] > time()) {

                        // 计算剩余秒数
                        $remainingSeconds = $info['sbjzrq'] - time();

                        if ($remainingSeconds >= 86400) { // 大于等于 1 天
                            // 计算剩余天数
                            $remainingDays = floor($remainingSeconds / 86400);
                            $info['syts']  = "{$remainingDays}天";
                        } else {
                            // 小于 1 天，计算剩余小时数
                            $remainingHours = floor($remainingSeconds / 3600);
                            $info['syts']   = "{$remainingHours}小时";
                        }
                    } else {
                        $info['syts'] = '已结束';
                    }

                } else {
                    $info['syts'] = '';
                }

            } else {

                $info['syts'] = '长期';
            }


            $dy['zc_info'] = $info;

        }


        return_msg(200, '查询成功', $list);
    }


    //取消政策订阅
    public function quxiaoZcDingyue()
    {
        $zc_id   = input('zc_id');
        $user_id = input('user_id');

        if (empty($zc_id) || empty($user_id)) {
            return_error('缺少参数');
        }

        Db::name("data_zhengceku_user_dy")->where('user_id', $user_id)->where('zc_id', $zc_id)->delete();

        return_msg(200, '操作成功');
    }

    public function checkSubscription(){
        $zc_id   = input('zc_id');
        $user_id = input('user_id');


        if (empty($zc_id) || empty($user_id)) {
            return_error('缺少参数');
        }

        $is_dy = Db::name("data_zhengceku_user_dy")->where('user_id', $user_id)->where('zc_id', $zc_id)->count();


        return_msg(200, '查看成功',['is_dy'=>$is_dy]);
    }

    //查看我的企业信息
    public function getMyQyxx()
    {
        $user_id = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数');
        }
        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();

        if (empty($rz_info)) {
            return_error('企业未认证');
        } else {

            $info = Db::name("data_qiye_xinxiku")->where('id', $rz_info['qrxxk_id'])->field('id,clbj,qyxctu,zycp,cptl')->find();

            if (!empty($info['qyxctu'])) {
                $info['qyxctu'] = explode(',', $info['qyxctu']);
            }

            if (!empty($info['cptl'])) {
                $info['cptl'] = explode(',', $info['cptl']);
            }

            return_msg(200, '获取成功', $info);
        }

    }

    //修改企业信息
    public function xiugaiMyqqxx()
    {

        $id           = input('id');
        $data['clbj'] = input('clbj');
        $data['zycp'] = input('zycp');
        $user_id      = input('user_id');

        $qyxctu_array = Request::post('qyxctu/a');
        $cptl_array   = Request::post('cptl/a');

        if (empty($id)) {
            return_error('缺少id');
        }

        if (empty($user_id)) {
            return_error('缺少参数');
        }

        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();

        if (empty($rz_info)) {
            return_error('企业未认证');
        }

        if ($rz_info['qrxxk_id'] != $id) {
            return_error('企业认证信息不匹配');
        }

        $data['qyxctu'] = '';
        if (empty($qyxctu_array)) {
            $data['qyxctu'] = implode(',', $qyxctu_array);
        }

        $data['cptl'] = '';
        if (empty($cptl_array)) {
            $data['cptl'] = implode(',', $cptl_array);
        }

        Db::name("data_qiye_xinxiku")->where('id', $id)->update($data);

        return_msg(200, '操作成功');
    }


    //查看企呼我应跟进
    public function chakanQhwyGenjin()
    {

        $id = input('id');

        if (empty($id)) {
            return_error('缺少id');
        }

        $list = Db::name("data_qhwy_user_genjin")->where('qhwy_id', $id)->select()->toArray();

        foreach ($list as &$item) {
            $item['cl_time_txt'] = date('Y-m-d', $item['cl_time']);

            if (!empty($item['cluser_id'])) {
                $item['cluser_name'] = Db::name("data_user")->where('id', $item['cluser_id'])->value('nickname');
            } else {
                $item['cluser_name'] = '';
            }
        }

        return_msg(200, '查询成功', $list);
    }


    //我要纠错提交内容
    public function tijiaoWyjc()
    {

        $user_id    = input('user_id');
        $neirong    = input('neirong');
        $imgs_array = Request::post('imgs/a');

        if (empty($user_id)) {
            return_error('缺少参数');
        }

        $img = '';
        if (!empty($imgs_array)) {
            $img = implode(',', $imgs_array);
        }

        Db::name("data_wyjc_user")->insert(['user_id' => $user_id, 'neirong' => $neirong, 'imgs' => $img, 'tj_time' => time()]);

        return_msg(200, '提交成功');
    }


    //获取单位列表
    public function getDanweiList(){

        $list = Db::name("data_jichu_danwei")->where('deleted',0)->select()->toArray();

        return_msg(200, '查询成功', $list);
    }

    //获取科室列表
    public function getKeshiList(){

        $dw_id = input('dw_id');

        if(empty($dw_id)){
            return_error('缺少参数dw_id');
        }
        $list = Db::name("data_jichu_keshi")->where('deleted',0)->where('dw_id',$dw_id)->select()->toArray();

        return_msg(200, '查询成功', $list);
    }
    //投诉
    public function tousu(){
        $user_id    = input('user_id');
        $qymc    = input('qymc');
        $tsrdh    = input('tsrdh');
        $tsrxm    = input('tsrxm');
        $dw_id    = input('dw_id');
        $keshi_id    = input('keshi_id');
        $tsnr    = input('tsnr');
        $tsimg = Request::post('tsimg/a');

        if (empty($user_id)) {
            return_error('缺少参数user_id');
        }


        $rz_info = Db::name('data_qiye_rzinfo')->where('user_id', $user_id)->where('deleted', 0)->find();
        if (empty($rz_info)) {
            return_error('请先完成企业认证');
        }

        $img = '';
        if (!empty($tsimg)) {
            $img = implode(',', $tsimg);
        }

        $data_tousu = [
            'user_id'=>$user_id,
            'qymc'=>$qymc,
            'tsrdh'=>$tsrdh,
            'tsrxm'=>$tsrxm,
            'dw_id'=>$dw_id,
            'keshi_id'=>$keshi_id,
            'tsnr'=>$tsnr,
            'tsimg'=>$img,
            'create_time'=>time(),
            'clzt'=>1,
        ];

        Db::name("data_tousu")->insert($data_tousu);

        return_msg(200, '提交成功');
    }

    //我的投诉列表
    public function getTousuList(){
        $user_id    = input('user_id');
        if (empty($user_id)) {
            return_error('缺少参数user_id');
        }

        $list = Db::name("data_tousu")->where('user_id',$user_id)->select()->toArray();

        foreach ($list as &$item){
            if(empty($item['dw_id'])){
                $item['dw_name'] = '';
            }else{
                $item['dw_name'] = Db::name("data_jichu_danwei")->where('id',$item['dw_id'])->value('name');
            }


            if(empty($item['keshi_id'])){
                $item['keshi_name'] = '';
            }else{
                $item['keshi_name'] = Db::name("data_jichu_keshi")->where('id',$item['keshi_id'])->value('name');
            }

            if(!empty($item['tsimg'])){
                $item['tsimg_list'] = explode(',',$item['tsimg']);
            }else{
                $item['tsimg_list'] = [];
            }

        }
        return_msg(200, '成功',$list);
    }


    //获取企业所在地
    public function getQyszdList(){

        $list = Db::name("data_qyszd")->where('deleted',0)->select()->toArray();

        return_msg(200, '查询成功', $list);
    }

    //提交企业信息
    public function tijiaoQyxx(){
        $user_id = input('user_id');
        $sbr_xm = input('sbr_xm');//法人姓名
        $qymc = input('qymc');//企业名称
        $tyxydm = input('tyxydm');//统一信用代码
        $qybq = input('qybq');//企业标签
        $qyszd_id = input('qyszd_id');//企业所在地
        $yyzz = input('yyzz');//营业执照


        if(empty($user_id)){
            return_error('缺少参数');
        }

        $user_info = Db::name("data_user")->where('id',$user_id)->find();

        $is_tijiao = Db::name("data_qiye_rzinfo_dsh")->where('user_id',$user_id)->where('sh_status',0)->count();
        if(!empty($is_tijiao)){
            return_error('有待审核的记录');
        }

        $data['user_id'] = $user_id;
        $data['sbr_xm'] = $sbr_xm;
        $data['qymc'] = $qymc;
        $data['tyxydm'] = $tyxydm;
        $data['qyszd_id'] = $qyszd_id;
        $data['yyzz'] = $yyzz;
        $data['sbr_phone'] = $user_info['phone'];
        $data['qybq'] = $qybq;

        Db::name("data_qiye_rzinfo_dsh")->insert($data);

        return_msg(200,'提交成功');
    }

    //获取企业标签（新）
    public function getNewQybqList(){

        $list = Db::name("data_qiye_biaoqian")->where('deleted',0)->where('status',1)->select()->toArray();

        return_msg(200,'查询成功',$list);
    }
}
